import django_filters.rest_framework
from django.shortcuts import render
from django_filters import FilterSet
from rest_framework.response import Response
from rest_framework.views import APIView

# Create your views here.
from rest_framework.viewsets import ModelViewSet
from member import models
from member.ser import MemberSer,LevelSer
from rest_framework.pagination import PageNumberPagination
class Page(PageNumberPagination):
    page_size = 2
    page_size_query_param = 'size'
class Filter(FilterSet):
    cname=django_filters.CharFilter(field_name='name',lookup_expr='contains')

    class Meta:
        model = models.Member
        fields = ['level','phone']
class LevelView(ModelViewSet):
    queryset = models.Level.objects.all()
    serializer_class = LevelSer
class MemberView(ModelViewSet):
    queryset = models.Member.objects.filter(isdel=False)

    serializer_class = MemberSer
    pagination_class = Page
    filter_backends = [django_filters.rest_framework.DjangoFilterBackend]
    filterset_class = Filter




